var userName;
var password;

$(document).ready(function() {
//	userName = request.getAttribute("userName");
//	if(userName != null){
//		boxLogin.style.display = 'none';
//		document.getElementById("welcomeName").innerHTML = data;
//		boxWelcome.style.display = '';
//	}
});

function logIn(){
	userName = document.getElementById("userName").value;
	password = document.getElementById("password").value;
	var boxLogin = document.getElementById("boxLogin");
	var boxWelcome = document.getElementById("boxWelcome");
	var userManager = document.getElementById("menu-item-3");
	
	$.ajax ({
		   type : "POST",
		   url : "/MathDict/login.do",
		   data : {
			   message: "kiem tra dang nhap",
			   userName : userName,
			   password : password
		   },
		   success : function(data) {
			   if (!("error"== data)){ 
				   boxLogin.style.display = 'none';
				   document.getElementById("welcomeName").innerHTML = data;
				   boxWelcome.style.display = '';
				   if("admin"==data){
					   userManager.style.display = '';
				   }
			   }
		   },
		   error : function(e) {
		    alert('Error ' + e);
		   }
		  });
	
}
function logOut1(){
	userName = document.getElementById("userName").value;
	password = document.getElementById("password").value;
	var boxLogin = document.getElementById("boxLogin");
	var boxWelcome = document.getElementById("boxWelcome");
	var userManager = document.getElementById("menu-item-3");
	
	$.ajax ({
		   type : "POST",
		   url : "/MathDict/logout.do",
		   data : {
			   message: "Thoat",
		   },
		   success : function(data) {
			   if (!("error"== data)){ 
				   boxLogin.style.display = '';
				   boxWelcome.style.display = 'none';
				   userManager.style.display = 'none';
			   }
		   },
		   error : function(e) {
		    alert('Error ' + e);
		   }
		  });
	
}
function logOut2(){
	userName = document.getElementById("userName").value;
	password = document.getElementById("password").value;
	var boxLogin = document.getElementById("boxLogin");
	var boxWelcome2 = document.getElementById("boxWelcome2");
	var userManager = document.getElementById("menu-item-3");
	
	$.ajax ({
		   type : "POST",
		   url : "/MathDict/logout.do",
		   data : {
			   message: "Thoat",
		   },
		   success : function(data) {
			   if (!("error"== data)){ 
				   boxLogin.style.display = '';
				   boxWelcome2.style.display = 'none';
				   userManager.style.display = 'none';
			   }
		   },
		   error : function(e) {
		    alert('Error ' + e);
		   }
		  });
	
}

function clear(){
	alert('adfasdfsd');
		document.getElementById('tbMean').value = "";
		document.getElementById('tbWord').value = "";
		document.getElementById('filePath').value = "";
}
